<script setup lang="ts">
import { ArrowRight } from "@element-plus/icons-vue";
import { onMounted, ref } from "vue";
import { getUserInfo, type UserInfo } from "@/api/user";
import { useUserStoreHook } from "@/store/modules/user-token";

defineOptions({
  name: "user-info",
});

const BREADLIST = [
  { name: "用户中心", path: "#" },
  { name: "基本信息", path: "/user/info" },
];

let userInfo = ref<UserInfo>({
  phone: '',
  point: 0,
  qqnum: '',
  rpgname: '',
  unit: '',
  useremail: '',
  username: ''
});

const logout = () => {
  console.log('退出登录');
}
onMounted(() => {
  getUserInfo().then((res) => {
    userInfo.value = res.myinfo;
  });
});
</script>

<template>
  <el-breadcrumb :separator-icon="ArrowRight" class="pb-[12px]">
    <el-breadcrumb-item v-for="item in BREADLIST" :to="item.path">{{
      item.name
    }}</el-breadcrumb-item>
  </el-breadcrumb>
  <!-- 奖品信息表格 -->
  <div class="w-full flex">
    <el-card class="flex-1">
      <template #header>
        <div>基本信息</div>
      </template>

      <div class="p-4">
        <h1 class="block mt-1 text-lg leading-tight font-medium text-black">
          用户名: {{ userInfo.username }}
        </h1>
        <div class="flex">
          <div class="flex flex-col w-[70px]">
            <p class="mt-2 text-gray-500">单位:</p>
            <p class="mt-2 text-gray-500">课题组:</p>
            <p class="mt-2 text-gray-500">电话:</p>
            <p class="mt-2 text-gray-500">邮箱:</p>
            <p class="mt-2 text-gray-500">积分:</p>
          </div>
          <div class="flex flex-col">
            <p class="mt-2 text-gray-500">
              <span>{{ userInfo.unit || "未填写" }}</span>
            </p>
            <p class="mt-2 text-gray-500">
              <span>{{ userInfo.rpgname || "未填写" }}</span>
            </p>
            <p class="mt-2 text-gray-500">
              <span>{{ userInfo.phone || "未填写" }}</span>
            </p>
            <p class="mt-2 text-gray-500">
              <span>{{ userInfo.useremail || "未填写" }}</span>
            </p>
            <p class="mt-2 text-gray-500">
              <span>{{ userInfo.point || "0" }}</span>
            </p>
          </div>
        </div>
        <el-button type="default"  @click="useUserStoreHook().logOut">退出登录</el-button>
      </div>
    </el-card>
  </div>
</template>

<style lang="scss" scoped></style>
